package DAO;

import hibernate.HibernateUtil;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import clases.Especialidad;

public class EspecialidadesDAO {

	SessionFactory factory;
	
	public EspecialidadesDAO(){
		
		factory= HibernateUtil.getSessionFactory();
	}	
	
	public void saveOrUpdate(Especialidad es) {
		
		Session session=factory.openSession();
		Transaction tx=session.beginTransaction();
		session.saveOrUpdate(es);
		tx.commit();
		session.close();
	}
	
	
	public void delete(Especialidad es) {
		Session session=factory.openSession();
		Transaction tx=session.beginTransaction();
		session.delete(es);
		tx.commit();
		session.close();
	}

}
